import { Controller, Get } from '@nestjs/common';
import { AnalyticsService } from './analytics.service';
import { ApiTags } from '@nestjs/swagger';
import { JwtPass } from '@/core/decorator';
import { AdminAnalyticsSummaryResDto } from './dto/admin-analytics.dto';
import { UserService } from '../user/user.service';

@ApiTags('后台/事件')
@Controller('admin/analytics')
export class AdminAnalyticsController {
  constructor(
    private readonly analyticsService: AnalyticsService,
    private readonly userService: UserService,
  ) {}

  /**
   * 事件总览
   */
  @Get()
  @JwtPass()
  async analyticsSummary(): Promise<AdminAnalyticsSummaryResDto> {
    const analytics = await this.analyticsService.summary();
    const userCount = await this.userService.count();

    // TODO ，补充一个今日打卡数
    return {
      userCount,
      analytics,
    };
  }
}
